package javase.javase01.exercise09;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;

/**
 * @author: Gan
 * @date 2021/4/14 0014 14:59
 * @description:
 **/
public class StringBuildDemo {
    public static void main(String[] args) throws ParseException {
        StringBuilder bu1 = new StringBuilder();
        //使用append方法，无需接收返回值，就是其本身。
        bu1.append(2.4 + " ").append(2 + " ").append('c' + " ");
        System.out.println(bu1);
        //c 2 4.2
        System.out.println(bu1.reverse());
        int[] arr1 = {1, 2, 3, 4, 5, 6, 7};
        int[] arr2 = {9, 4, 5, 6, 2, 5, 4};
        System.arraycopy(arr1, 0, arr2, 0, 3);
        for (int i : arr2) {
            System.out.print(i + " ");
        }
        System.out.print('\n');
        System.out.println(Arrays.toString(arr2));
        String str1 = "aad";
        String str2 = "uad";
        System.out.println(str1.concat(str2));
        //装箱 包装类
        Integer in = new Integer(2);
        System.out.println(in);
        Integer i = Integer.valueOf(3);
        System.out.println(i);
        //将string字符串转换成字符数组
        System.out.println(str1.toCharArray());
        char[] ch = str1.toCharArray();
        System.out.println(ch.length);
        //int indexOf(int ch)
        //获取指定字符第一次在字符串出现的位置，没有就返回-1
        int c = str2.indexOf('a');
        System.out.println(c);
        String s = "wo ai liu yi fei";
        String[] str = s.split(" ");
        System.out.println(Arrays.toString(str));
        String s1 = "1998-05-29";
        Date date = new Date();
        DateFormat format = new SimpleDateFormat("yyyy‐MM‐dd HH:mm:ss");
        Date birthday = format.parse(s);
        long n = (date.getTime() - birthday.getTime()) / (3600 * 24 * 1000);
        System.out.println("1998年5月29的我，共来到这世界"+n+"天");
        //System.exit(0);

    }
}
